<template>
  <div id="app">
<!--    <div id="nav">-->
<!--      <router-link to="/">Home</router-link> |-->
<!--      <router-link to="/about">About</router-link>-->
<!--    </div>-->
      <keep-alive>
          <router-view v-if="$route.meta.keepAlive"></router-view>
      </keep-alive>
      <router-view v-if="!$route.meta.keepAlive"></router-view>
  </div>
</template>
<script lang="ts">
    import {Component} from "vue-property-decorator";
    import Sence from "./sence/Sence";

    @Component({
        components: {}
    })

    export default class Index extends Sence {
        public mounted(): void {
            let query:any=this.GetRequest(window.location.href);
            if (query.token) {
                localStorage.setItem('token',query.token.substr(0,query.token.length-2));
                this.freshuser();
            }
            this.post('api/v1/getSiteConfig',{}).then((res:any)=>{
                let oMeta1 = document.createElement('meta');
                let oMeta2 = document.createElement('meta');
                oMeta1.content = res.data.keywords;
                oMeta1.name = 'keywords';
                oMeta2.content = res.data.description;
                oMeta2.name = 'description';
                document.getElementsByTagName('head')[0].appendChild(oMeta1);
                document.getElementsByTagName('head')[0].appendChild(oMeta2);
            });
            this.towxlogin()
        }

        //微信登录
        public towxlogin():void{
            let ua:any = window.navigator.userAgent.toLowerCase();
            // console.log( window.location.href);
            //通过正则表达式匹配ua中是否含有MicroMessenger字符串
            if(ua.match(/MicroMessenger/i) == 'micromessenger' && !localStorage.getItem('token')){
                location.href=this.apiurl+'wxLogin?referer='+encodeURI(window.location.href)
            }
        }
    }


</script>
<style lang="stylus" >

#app
  font-family 'Avenir', Helvetica, Arial, sans-serif
  -webkit-font-smoothing antialiased
  -moz-osx-font-smoothing grayscale
  text-align center
  color #2c3e50

.image-preview-custom-header
      width 100vw
      box-sizing border-box
      text-align center
      padding 15px 0
      background #333
      color white
      font-size 14px

#nav
  padding 30px
  a
    font-weight bold
    color #2c3e50
    &.router-link-exact-active
      color #42b983
</style>
